home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / develop / libsrc11.arc / XGBYTSPI.C < prev   
C/C++ Source or Header  |  1989-04-27  |  853b  |  40 lines

  1. /*    xgbytspi.c 4.3        */
  2. /*F****************************************************************************
  3.  
  4. FUNCTION NAME:    xgbytspi
  5.  
  6. ACTION:        Reads/writes a byte from the SPI Port.
  7.         Returns an integer with the following format:
  8.             Bits 15-8 = SPSR register
  9.             Bits  7-0 = Data read
  10.  
  11. PARAMETERS:
  12.         byte_value:    value to be output to the SPI port.
  13.  
  14. RETURNS:    (int)    byte_read:    Data plus status read from
  15.                     the SPI port.
  16.  
  17. ******************************************************************************/
  18.  
  19. #include <hc11/io.h>
  20. #include <hc11/spi.h>
  21. #include <hc11/directives.h>
  22.  
  23. SMALL
  24. unsigned xgbytspi(byte_value)
  25.  
  26.     int    byte_value;
  27.  
  28.     {
  29.  
  30.     HC11.SPCR |= SPE;
  31.  
  32.     HC11.SPSRDAT.DATAREG = byte_value;
  33.  
  34.     while ((HC11.SPSRDAT.STATUS & SPIF) == 0)
  35.         ;        /* null statement */
  36.  
  37.     return (HC11.SPSRDAT.STATDATA);
  38.  
  39.     }    /* end of xgbytspi    */
  40.